package cn.mogugo.joke.manager;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import cn.mogugo.comm.BaseManager;
import cn.mogugo.comm.PageSupport;
import cn.mogugo.joke.model.JokeCategory;

public class JokeCategoryManager   extends BaseManager{

	public List getAll(){
		String hql = "from JokeCategory jc order by jc.joke_number desc";
		return this.baseDao.getByHQL(hql, null);
	}
	
	public List getListOrderTld(Integer pageSize){
		String hql = "from JokeCategory jc where jc.joke_number > 0 order by jc.joke_number desc";
		if(pageSize == null || pageSize == 0){
			return this.baseDao.getByHQL(hql, null);
		}else{
			PageSupport ps = this.baseDao.findPageByHql(hql, pageSize, 1, null);
			return ps.getItems();			
		}
	}
	
	
	public List getAllWithOutCur(Integer categoryId){
		String hql = "from JokeCategory jc where jc.id <>:categoryId order by jc.joke_number desc";
		Map map = new HashMap();
		map.put("categoryId", categoryId);
		return this.baseDao.getByHQL(hql, map);
	}
	
	public JokeCategory getById(Integer id){
		return (JokeCategory)this.baseDao.get(JokeCategory.class, id);
	}

}
